﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Hkwl.WorldExpo.Merchant.Common;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.Service;

namespace Hkwl.WorldExpo.Merchant.Web
{
    public partial class GroupCreate : BaseCheckPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            NxGroup nxGroup = new NxGroup();
            if (Session["MerchantId"] != null)
            {
                if (txtGroup.Text != null)
                {
                    nxGroup.GroupName = txtGroup.Text.Trim();
                    nxGroup.MerchantId = int.Parse(Session["MerchantId"].ToString());
                    if (ServiceLocator.IClientService.InsertNxGroup(nxGroup))
                    {
                        JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "SAVE_CLIENT_GROUP_SUCCESS") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','AddClientToGroup.aspx?GroupId=" + nxGroup.GroupId + "')", this.Page);
                    }
                    else
                    {
                        JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "SAVE_CLIENT_GROUP_FAILED") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','GroupCreate.aspx')", this.Page);
                    }

                }
                else
                {
                    JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "ENTER_THE_GROUP_NAME") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','GroupCreate.aspx')", this.Page);
                }
            }
        }
    }
}
